import java.util.Arrays;

/**
 * @ClassName: Demo01
 * @Author: 王延
 * @Description :
 */
public class Demo01 {
    public static void main(String[] args) {
        //System.out.println(test("test"));
        test02(2, 4, 6, 10, 18, 19, 20);
    }

    private static void test02(int... is) {
        if (is.length == 1) {
            System.out.println(is[0]);
            return;
        }
        //坐标排序
        Arrays.sort(is);
        int oldTime = 0;
        int time;
        int index = 0;
        //依次遍历坐标
        for (int i = 0; i < is.length; i++) {
            time = 0;
            //遍历当前坐标到抵达所有坐标和
            for (int k : is) {
                time += Math.abs(is[i] - k);
            }
            if (i == 0) {
                oldTime = time;
                continue;
            }
            //获取相对时间较短,记录坐标
            if (time < oldTime) {
                index = is[i];
                oldTime = time;
            }
        }
        System.out.println(index);
    }

    private static boolean test(String str) {
        if (str.length() < 2) {
            return true;
        }
        //进行遍历的字符数组
        char[] chars = str.toCharArray();
        //末尾元素下标
        int k = chars.length - 1;
        //头尾比较遍历,奇数可直接忽略
        for (int i = 1; i < chars.length / 2; i++) {
            //依此前后比较
            if (chars[i - 1] == chars[k]) {
                k--;
                //相同进入下次循环
                continue;
            } else {
                //不同直接返回
                return false;
            }
        }
        return true;
    }
}
